<?php
 include "template/header.php";
 
 if(isset($_SESSION['tipo_usuario'])){
 
	$id = $_SESSION['tipo_usuario'];
	
	if($id = 1){
		$med = $_POST['med'];
		$sql = "select * from consulta_disponivel where id_medico = '$med' and status like 'disponivel'";
		
		$rs = mysql_query($sql, $con);
		echo '<h1> Horarios dispoveis </h1>';
		if($rs){
			while($vetor = mysql_fetch_array($rs)){
				
				$valor =  substr($vetor['data'], 0, 10);
				$data = substr($valor, 8, 10).'/';
				$data2 = substr($vetor['data'], 5, 2);
				$data1 = "/".substr($valor, 0,4);
				$hora = substr($vetor['data'], 11,5);
				$fdata = $data.$data2.$data1;
				echo '<form action="finalizar_agendamento.php" method="POST">';
				echo $fdata.' - '.$hora.' - ';
				$id_med = $vetor['id_medico'];
				$sql2 = "select * from medicos where crm like '$id_med'";
				$rs2 = mysql_query($sql2, $con);
				while($vetor2 = mysql_fetch_array($rs2)){
					echo $vetor2['nome'];
					
					?>
			
				
				<input type="radio" name="cd" value="<?php echo $vetor['id'];  ?>">
				<input type="hidden" name="med" value="<?php echo $med;  ?>">
				<br/>
			
			
			<?php
				
				}
			
				
			
			}
			
			echo "<br/><input type='submit' value='marcar'> </form>";
			
		
		}
		else{
			
		}
	
	
	}
 
 
 }
 
 
 
 
 include "template/footer.php";
?>